﻿using System;

namespace EmbeddedSharp.Core {
    /// <summary>
    /// Display the internal representation of an expression.
    /// 
    /// Usage:
    /// qualifiedForm(expression);
    /// </summary>
    [Function("qualifiedForm", "Show the qualified form of the expression", "a=0;b=0;c=0;d=qualifiedForm(a+b+c);", "d==\"plus(a, b, c)\";")]
    public class QualifiedFormNode : FuncNode {

        /// <summary>
        /// Default constructor
        /// </summary>
        public QualifiedFormNode()
            : base("qualifiedForm") {
        }

        public override object Evaluate() {
            if (Parameters.Count < 1) {
                throw new ArgumentException(
                    "usage: qualifiedForm(expression)");
            }

            FunctionFormExpressionTranslator dec
                = new FunctionFormExpressionTranslator();
            string expr = dec.Translate(Parameters[0]);

            return expr;
        }
    }
}
